#include <iostream>
#include <vector>

using namespace std;

class Widget
{
protected:
    int x_{0};
    int y_{0};

public:
    Widget() {}
    Widget(int x, int y) : x_(x), y_(y) {};
    ~Widget() {}

    void Move(int x, int y)
    {
        x_ = x;
        y_ = y;
    }

    virtual void Draw() const { cout << "Widget Draw: ( " << x_ << ", " << y_ << " )" << endl; }
};

class Rect : public Widget
{
public:
    Rect() {}
    Rect(int x, int y) : Widget(x, y) {}
    ~Rect() {}

    void Draw() const { cout << "Rect Draw: ( " << x_ << ", " << y_ << " )" << endl; }
};

class Circle : public Widget
{
public:
    Circle() {}
    Circle(int x, int y) : Widget(x, y) {}
    ~Circle() {}

    void Draw() const { cout << "Circle Draw: ( " << x_ << ", " << y_ << " )" << endl; }
};

class Scence
{
private:
    vector<Widget *> widgets_;

public:
    Scence() {}
    ~Scence()
    {
        Close();
    }

    void Close()
    {
        for (auto &&i : widgets_)
        {
            delete i;
        }

        widgets_.clear();
    }

    void Add(Widget *w)
    {
        widgets_.push_back(w);
    }

    void DrawAll()
    {
        for (auto &&i : widgets_)
        {
            i->Draw();
        }
    }
};

void DrawWidget(Widget *w)
{
    w->Draw();
}

void DrawWidget(Widget &w)
{
    w.Draw();
}

int main(int argc, char const *argv[])
{
    {
        Rect re;
        re.Move(100, 120);

        Circle ci(122, 121);

        re.Draw();
        ci.Draw();

        cout << endl;

        DrawWidget(re);
        DrawWidget(ci);
        cout << endl;
    }
    {
        Scence sec;

        sec.Add(new Rect(121, 12));
        sec.Add(new Circle(11, 122));

        sec.DrawAll();
    }
    return 0;
}
